package com.example.photography.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.photography.Activity.Menu_Activity;
import com.example.photography.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 已选择标签
 */
public class Menu_Selected extends MyBaseAdapter {
    public Menu_Selected(List list, Context context) {
        super(list, context);
    }


    @Override
    public View myGetView(int position, View convertView) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_label_gv_select, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        String t = (String) list.get(position);
        viewHolder.tvLabel.setText(t);

        if (Menu_Activity.editsign) {//可编辑模式
            viewHolder.ivEdit.setVisibility(View.VISIBLE);
            viewHolder.rlEdit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Menu_Activity.listselect.remove(t);
                    Menu_Activity.list.add(t);
                    Menu_Activity.refresh();
                }
            });
        } else {
            viewHolder.ivEdit.setVisibility(View.INVISIBLE);
            // TODO: 2020/10/15 以后换一种方式禁用点击事件
            viewHolder.rlEdit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                }
            });
        }
        if (!Menu_Activity.editsign){
        }
        return convertView;
    }



    static
    class ViewHolder {
        @BindView(R.id.tv_label)
        TextView tvLabel;
        @BindView(R.id.iv_edit)
        ImageView ivEdit;
        @BindView(R.id.rl_edit)
        RelativeLayout rlEdit;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
